package com.ruoyi.hospital.controller.shop;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.hospital.domain.shop.ShopProductTags;
import com.ruoyi.hospital.service.shop.IShopProductTagsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 商品标签Controller
 * 
 * @author wendao
 * @date 2024-08-19
 */
@RestController
@RequestMapping("/hospital/productTags")
public class ShopProductTagsController extends BaseController
{
    @Autowired
    private IShopProductTagsService shopProductTagsService;

    /**
     * 查询商品标签列表
     */
    @PreAuthorize("@ss.hasPermi('hospital:productTags:list')")
    @GetMapping("/list")
    public TableDataInfo list(ShopProductTags shopProductTags)
    {
        startPage();
        List<ShopProductTags> list = shopProductTagsService.selectShopProductTagsList(shopProductTags);
        return getDataTable(list);
    }

    /**
     * 导出商品标签列表
     */
    @PreAuthorize("@ss.hasPermi('hospital:productTags:export')")
    @Log(title = "商品标签", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ShopProductTags shopProductTags)
    {
        List<ShopProductTags> list = shopProductTagsService.selectShopProductTagsList(shopProductTags);
        ExcelUtil<ShopProductTags> util = new ExcelUtil<ShopProductTags>(ShopProductTags.class);
        util.exportExcel(response, list, "商品标签数据");
    }

    /**
     * 获取商品标签详细信息
     */
    @PreAuthorize("@ss.hasPermi('hospital:productTags:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(shopProductTagsService.selectShopProductTagsById(id));
    }

    /**
     * 新增商品标签
     */
    @PreAuthorize("@ss.hasPermi('hospital:productTags:add')")
    @Log(title = "商品标签", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ShopProductTags shopProductTags)
    {
        return toAjax(shopProductTagsService.insertShopProductTags(shopProductTags));
    }

    /**
     * 修改商品标签
     */
    @PreAuthorize("@ss.hasPermi('hospital:productTags:edit')")
    @Log(title = "商品标签", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ShopProductTags shopProductTags)
    {
        return toAjax(shopProductTagsService.updateShopProductTags(shopProductTags));
    }

    /**
     * 删除商品标签
     */
    @PreAuthorize("@ss.hasPermi('hospital:productTags:remove')")
    @Log(title = "商品标签", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(shopProductTagsService.deleteShopProductTagsByIds(ids));
    }
}
